<template>
  <div>
    <!-- Form 弹窗-->

    <el-dialog
      class="alretconent tanchaungWH"
      title="问题解答"
      :visible.sync="dialogFormVisible"
    >
      <el-form :model="form" class="">
        <el-form-item>
          <el-row>
            <el-col :span="2">解答：</el-col>
            <el-col :span="12"
              ><el-input
                v-model="form.phone"
                autocomplete="off"
                class="tanchaunginput"
                  placeholder="请输入您的解决方法"
              ></el-input
            ></el-col>
          </el-row>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitqueding">确 定</el-button>
        <el-button @click="dialogFormVisible = false">取 消</el-button>
      </div>
    </el-dialog>

    <router-link to="/index/chufang" class="styleaddBingli router-link-active"
      >处方管理</router-link
    >
    <div class="bigwhite">
      <el-row :gutter="10">
        <el-col :span="4">
          <div class="grid-content bg-purple-dark">
            <el-input
              v-model="search"
              circle
              placeholder="请输入内容"
            ></el-input>
          </div>
        </el-col>
        <el-col :span="5">
          <div class="grid-content bg-purple-dark">
            <el-date-picker
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              v-model="date"
              type="date"
              placeholder="选择入院时间"
            >
            </el-date-picker>
          </div>
        </el-col>
        <el-col :span="4">
          <el-select v-model="kebie" placeholder="外科" class="formwidth">
            <el-option label="外科" value="waike"></el-option>
            <el-option label="内科" value="neike"></el-option>
            <el-option label="妇科" value="fuke"></el-option>
            <el-option label="神经科" value="shenjingke"></el-option>
          </el-select>
        </el-col>
        <el-col :span="2">
          <div class="grid-content bg-purple-dark">
            <el-button
              type="primary"
              @click="submit"
              icon="el-icon-search"
              circle
            ></el-button>
          </div>
        </el-col>
      </el-row>

      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection"> </el-table-column>
        <el-table-column label="住院号">
          <template slot-scope="scope">{{ scope.row.num }}</template>
        </el-table-column>
        <el-table-column label="姓名">
          <template slot-scope="scope">{{ scope.row.name }}</template>
        </el-table-column>
        <el-table-column label="性别">
          <template slot-scope="scope">{{ scope.row.sex }}</template>
        </el-table-column>
        <el-table-column label="年龄">
          <template slot-scope="scope">{{ scope.row.age }}</template>
        </el-table-column>
        <el-table-column label="日期">
          <template slot-scope="scope">
            {{ scope.row.date }}
          </template>
        </el-table-column>
        <el-table-column label="问题描述" width="180">
          <template slot-scope="scope">
            {{ scope.row.wenti }}
          </template>
        </el-table-column>
        <el-table-column label="主要症状" width="180">
          <template slot-scope="scope">
            {{ scope.row.zhengzhuang }}
          </template>
        </el-table-column>
        <el-table-column label="所用药物" width="180">
          <template slot-scope="scope">
            <div class="hideen">{{ scope.row.chufang }}</div>
          </template>
        </el-table-column>
        <el-table-column label="操作" class="cellwidth">
          <template slot-scope="scope">
            <el-button type="success"
            class="btnjieda"
              @click="dit(scope.row.chufang, scope.row.chuanghao)"
            >解答问题</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div style="margin-top: 20px">
        <el-button type="danger" @click="delmany">批量删除</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "chufang",
  data() {
    return {
      index: "",
      dialogFormVisible: false, //弹窗隐藏
      date: "",
      kebie: "外科",
      phone: "", //手机号
      zhuyuanhao: "",
      bingchuanghao: "",
      search: "",
      words: "",
      form: {
        phone: "", //弹窗数据
      },
      newtableDta: [],
      tableData: [
        // {
        //   date: "2016-05-03",
        //   name: "王小虎1",
        //   address: "上海市普陀区金沙江路 1518 弄",
        // }
        {
          num: "01",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3028,
          wenti:"感冒发烧流鼻涕",
          zhengzhuang:"头疼，恶心，食欲不振",
          doctors: "赵医师",
          nusers: "乔护士",
          status: "未住院",
          chufang:
            "红霉素，左氧氟沙星片",
          blo: false,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "02",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3029,
          wenti:"感冒发烧流鼻涕",
          zhengzhuang:"头疼，恶心，食欲不振",
          doctors: "赵医师",
          nusers: "乔护士",
          status: "已出院",
          chufang:
            "红霉素，左氧氟沙星片",
          blo: true,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "03",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3030,
          wenti:"感冒发烧流鼻涕",
          zhengzhuang:"头疼，恶心，食欲不振",
          doctors: "赵医师",
          nusers: "乔护士",
          status: "预住院",
          chufang:
            "红霉素，左氧氟沙星片",
          blo: false,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "04",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3031,
          wenti:"感冒发烧流鼻涕",
          zhengzhuang:"头疼，恶心，食欲不振",
          doctors: "赵医师",
          nusers: "乔护士",
          status: "未住院",
          chufang:
            "红霉素，左氧氟沙星片",
          blo: false,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "05",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3032,
          wenti:"感冒发烧流鼻涕",
          zhengzhuang:"头疼，恶心，食欲不振",
          doctors: "赵医师",
          nusers: "乔护士",
          status: "已住院",
          chufang:
            "红霉素，左氧氟沙星片",
          blo: true,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "06",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3033,
          wenti:"感冒发烧流鼻涕",
          zhengzhuang:"头疼，恶心，食欲不振",
          doctors: "赵医师",
          nusers: "乔护士",
          status: "已住院",
          chufang:
            "红霉素，左氧氟沙星片",
          blo: true,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
      ],
      multipleSelection: [],
      currentPage3: 5,
    };
  },
  //     mounted() {
  //   },
  methods: {
    dlele(num) {
      // var newarr=""
      for (let i = 0; i < this.tableData.length; i++) {
        if (this.tableData[i].chuanghao == num) {
          this.tableData.splice(i, 1);
          return;
        }
      }
    },
    submit() {
      console.log(this.search, this.date);
    },
    //修改处方
    submitqueding() {
      for (let i = 0; i < this.tableData.length; i++) {
        if (this.tableData[i].chuanghao == this.index) {
          this.tableData[i].chufang = this.form.phone;
          this.dialogFormVisible = false;
          return;
        }
      }
      // this.tableData.chufang=this.form.phone
      // console.log(this.tableData.chufang)
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    delmany() {
      console.log(this.multipleSelection);
      for (let i = 0; i < this.tableData.length; i++) {
        for (let j = 0; j < this.multipleSelection.length; j++) {
          if (this.tableData[i] == this.multipleSelection[j]) {
            this.tableData.splice(i, 1);
          }
        }
      }
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    dit() {
      //编辑
      //   console.log(i);
      //   console.log(index);
    //   this.index = index;
      this.dialogFormVisible = true;
    //   this.form.phone = i;
    },
  },
  computed: {},
};
</script>

<style lang="scss" scoped>
.router-link-active {
  background: #16dcb8;
  padding: 14px 35px;
  margin-left: 20px;

  border-top-left-radius: 30px;
  border-bottom-right-radius: 30px;
  color: white;
  display: inline-block;
  background-image: linear-gradient(to right, #2dc6e1, #14dfba);
}
.el-icon-edit {
  padding-right: 20px;
  font-size: 18px;
  color: #16dcb8;
}
.el-icon-circle-close {
  font-size: 18px;
  color: #16dcb8;
}
.hideen {
  overflow: hidden !important; //超出的文本隐藏
  text-overflow: ellipsis !important; //溢出用省略号显示
  white-space: nowrap !important;
}
.tanchaunginput /deep/ input {
  height: 200px;
  width: 400px;
  overflow: hidden !important; //超出的文本隐藏
  text-overflow: ellipsis !important; //溢出用省略号显示
  white-space: nowrap !important;
}
.tanchaungWH /deep/ .el-dialog {
  width: 610px;
}
.btnjieda{
    background: #16dcb8;
    border: none;
}
</style>